#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

typedef struct Node
{
    int _val;
    struct Node* _next;
}Node;

void PushBack(Node* pos, int x)
{
    if (NULL == pos)
        return;
    Node* newNode = (Node*)malloc(sizeof(Node));
    if (NULL == newNode)
    {
        perror("malloc");
        return;
    }
    newNode->_next = NULL;
    newNode->_val = x;

    pos->_next = newNode;
}


int main()
{
    Node* head = (Node*)malloc(sizeof(Node));
    head->_next = NULL;

    int n = 0;
    scanf("%d", &n);
    Node* pcur = head;
    for (int i = 0; i < n; i++)
    {
        int x = 0;
        scanf("%d", &x);
        PushBack(pcur, x);
        pcur = pcur->_next;
    }

    pcur = head->_next;
    int sum = 0;
    while (pcur)
    {
        sum += pcur->_val;
        pcur = pcur->_next;
    }

    printf("%d", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

typedef struct Node
{
    int _val;
    struct Node* _next;
}Node;

void PushBack(Node* pos, int x)
{
    if (NULL == pos)
        return;
    Node* newNode = (Node*)malloc(sizeof(Node));
    if (NULL == newNode)
    {
        perror("malloc");
        return;
    }
    newNode->_next = NULL;
    newNode->_val = x;

    pos->_next = newNode;
}


int main()
{
    Node* head = (Node*)malloc(sizeof(Node));
    head->_next = NULL;

    int n = 0, x = 0;
    scanf("%d %d", &n, &x);
    Node* pcur = head;
    for (int i = 0; i < n; i++)
    {
        int temp = 0;
        scanf("%d", &temp);
        PushBack(pcur, temp);
        pcur = pcur->_next;
    }

    pcur = head;
    while (pcur->_next)
    {
        if (pcur->_next->_val == x)
        {
            Node* del = pcur->_next;
            pcur->_next = pcur->_next->_next;
            free(del);
            del = NULL;
        }
        else
        {
            pcur = pcur->_next;
        }
    }

    pcur = head->_next;
    while (pcur)
    {
        printf("%d ", pcur->_val);
        pcur = pcur->_next;
    }
    return 0;
}